﻿@model ESupervision.Models.Comment
@{
    ViewBag.Title = "Document Information";

    ESupervision.Models.Document document = ViewBag.Document;
}
<h2>Details</h2>

<style>
    textarea {
        max-width: 100%;
    }
    /*div.row > label.col-lg-4 {
            text-align: right;
        }*/
    div.row > div.col-md-6 > div.row {
        margin-top: 10px;
    }
</style>
<div>
    <h4>Subject: @document.Subject</h4>
    <hr />
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title" id="panel-title">Information Attachement File<a class="anchorjs-link" href="#panel-title"><span class="anchorjs-icon"></span></a></h3>
        </div>
        <div class="row" style=" padding: 20px;">
            <div class="col-md-6">
                @*Show Detail Document*@
                <div class="row">
                    <label class="col-lg-4 ">Created User:</label>
                    <div class="col-lg-8">
                        @document.CreatedByUser.FullName
                    </div>
                </div>

                <div class="row">
                    <label class="col-lg-4 ">Created Time:</label>
                    <div class="col-lg-8">
                        @document.CreatedTime
                    </div>
                </div>

                <div class="row">
                    <label class="col-lg-4 ">Subject:</label>
                    <div class="col-lg-8">
                        <textarea class="form-control" rows="3" id="textArea" disabled="">@document.Subject</textarea>
                    </div>
                </div>
            </div>
            <div class="col-md-6">
                <div class="row">
                    <label class="col-lg-3 ">FileName:</label>
                    <div class="col-lg-9">
                        @document.AttachmentFile.FileName
                    </div>
                </div>
                <div class="row">
                    <label class="col-lg-3 ">Content:</label>
                    <div class="col-lg-9">
                        <a href="~/File?id=@(document.AttachmentFileID)" target="_blank">Download</a>
                    </div>
                </div>
                <div class="row">
                    <label class="col-lg-3 ">Body:</label>
                    <div class="col-lg-9">
                        <textarea class="form-control" rows="3" id="textArea" disabled="">@document.Body</textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="panel panel-success">
        <div class="panel-heading">
            <h3 class="panel-title" id="panel-title">List Comment<a class="anchorjs-link" href="#panel-title"><span class="anchorjs-icon"></span></a></h3>
        </div>
        @foreach (var item in document.Comments)
        {
            <div class="media" style="padding: 10px 30px 10px 30px;">
                <a class="pull-left" href="#">
                    <img class="media-object" src="~/Images/UnknownIcon.png" />
                </a>
                <div class="media-body">
                    <h4 class="media-heading">
                        @Html.DisplayFor(modelItem => item.User.FullName)
                        <small>@Html.DisplayFor(modelItem => item.CommentTime)</small>
                    </h4>
                    @Html.DisplayFor(modelItem => item.Content)
                </div>
            </div>
        }
    </div>
    <div class="panel panel-warning">
        <div class="panel-heading">
            <h3 class="panel-title" id="panel-title">Leave a Comment<a class="anchorjs-link" href="#panel-title"><span class="anchorjs-icon"></span></a></h3>
        </div>
        @using (Html.BeginForm("CreateComment", "Document"))
        {
            @Html.AntiForgeryToken()
            <div class="well">
                <div class="form-group">
                    @Html.TextAreaFor(model => model.Content, new { @cols = 300, @rows = 10 })
                    @Html.ValidationMessageFor(model => model.Content)
                    @Html.HiddenFor(model => model.DocumentID)
                    @Html.HiddenFor(model => model.UserId)
                </div>
                <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-pencil">PostComment</span></button>
            </div>
        }
    </div>
</div>

<p>
    @{if (User.IsInRole("Teacher"))
    {
        @Html.ActionLink("Back to List", "TeacherIndex")
    }
    else
    {
        @Html.ActionLink("Back to List", "Index")
    }
    }
</p>
